import 'package:ai_desktop_eidtor/common/y_button.dart';
import 'package:ai_desktop_eidtor/common/y_field.dart';
import 'package:flutter/material.dart';
import 'package:get/get.dart';

import 'login_logic.dart';
import 'login_state.dart';

class LoginPage extends StatelessWidget {
  const LoginPage({Key? key}) : super(key: key);

  @override
  Widget build(BuildContext context) {
    final LoginLogic logic = Get.put(LoginLogic());
    final LoginState state = Get.find<LoginLogic>().state;

    return Scaffold(
      backgroundColor: Colors.white,
      body: Column(
        crossAxisAlignment: CrossAxisAlignment.center,
        mainAxisAlignment: MainAxisAlignment.center,
        children: [
          Center(
            child: Container(
              decoration: BoxDecoration(
                borderRadius: BorderRadius.circular(10),
                border: Border.all(width: 1, color: Colors.blue),
              ),
              width: 300,
              padding: EdgeInsets.only(left: 16, right: 16),
              child: YField(
                hintText: '请输入笔名',
                textAlign: TextAlign.left,
                hintStyle: TextStyle(fontSize: 15, color: Colors.grey),
                controller: logic.authorField,
              ),
            ),
          ),
          SizedBox(height: 10),
          Center(
            child: Container(
              decoration: BoxDecoration(
                borderRadius: BorderRadius.circular(10),
                border: Border.all(width: 1, color: Colors.blue),
              ),
              width: 300,
              padding: EdgeInsets.only(left: 16, right: 16),
              child: YField(
                hintText: '请输入用户名',
                textAlign: TextAlign.left,
                hintStyle: TextStyle(fontSize: 15, color: Colors.grey),
                controller: logic.nameField,
              ),
            ),
          ),
          SizedBox(height: 10),
          Center(
            child: Container(
              decoration: BoxDecoration(
                borderRadius: BorderRadius.circular(10),
                border: Border.all(width: 1, color: Colors.blue),
              ),
              width: 300,
              padding: EdgeInsets.only(left: 16, right: 16),
              child: YField(
                hintText: '请输入密码',
                textAlign: TextAlign.left,
                hintStyle: TextStyle(fontSize: 15, color: Colors.grey),
                controller: logic.passwordField,
              ),
            ),
          ),
          SizedBox(height: 20),
          SizedBox(
            width: 300,
            child: YButton(
              text: '登录',
              onPressed: () {
                logic.login();
              },
              isFullWidth: true,
            ),
          ),
        ],
      ),
    );
  }
}
